﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EventfullPerson
{
    class Person
    {
        private string firstName;
        private string lastName;
        private char gender;
        private DateTime birthDate;
        public event EventHandler PropertyChange;

        public Person(string firstName, string lastName, char gender, DateTime birthDate)
        {
            this.firstName = firstName;
            this.lastName = lastName;
            this.gender = gender;
            this.birthDate = birthDate;
        }

        protected void OnPropertyChange(string propertyName, object oldValue, object newValue)
        {
            if (PropertyChange != null)
            {
                PropertyChange.Invoke(this, new PropertyChangedEventArgs(propertyName,oldValue,newValue);
            }
        }

        public string FirstName
        {
            get
            {
                return firstName;
            }
            set
            {
                OnPropertyChange("FirstName", firstName, value);
                firstName = value;
            }
        }

        public string LastName
        {
            get
            {
                return lastName;
            }
            set
            {
                OnPropertyChange("LastName", firstName, value);
                lastName = value;
            }
        }

        public char Gender
        {
            get
            {
                return gender;
            }
            set
            {
                OnPropertyChange("Gender", firstName, value);
                gender = value;
            }
        }

        public DateTime BirthDate
        {
            get
            {
                return birthDate;
            }
            set
            {
                OnPropertyChange("BirthDate", firstName, value);
                birthDate = value;
            }
        }
    }
}
